package com.example.customaidl.aidl;

import android.os.Binder;
import android.os.IBinder;

public interface IBookManager extends android.os.IInterface {

    static final int TRANSACTION_getBookList = (IBinder.FIRST_CALL_TRANSACTION + 0);
    static final int TRANSACTION_addBook = (IBinder.FIRST_CALL_TRANSACTION + 1);
    static final int TRANSACTION_registerListener = (IBinder.FIRST_CALL_TRANSACTION + 2);
    static final int TRANSACTION_unregisterListener = (IBinder.FIRST_CALL_TRANSACTION + 3);

    java.util.List<Book> getBookList() throws android.os.RemoteException;

    void addBook(Book book) throws android.os.RemoteException;

    void registerListener(IOnBookListener listener) throws android.os.RemoteException;

    void unregisterListener(IOnBookListener listener) throws android.os.RemoteException;


    public static abstract class Stub extends Binder implements IBookManager {
        
        private static final String DESCRIPTOR = "com.example.aidl.IBookManager";

        /**
         * Cast an IBinder object into an com.example.aidl.IBookManager interface,
         * generating a proxy if needed.
         */
        public static IBookManager asInterface(android.os.IBinder obj) {
            if ((obj == null)) {
                return null;
            }
            android.os.IInterface iin = obj.queryLocalInterface(DESCRIPTOR);
            if (((iin != null) && (iin instanceof IBookManager))) {
                return ((IBookManager) iin);
            }
            return new IBookManager.Stub.Proxy(obj);
        }
        
//        @Override
//        public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws android.os.RemoteException {
//            String descriptor = DESCRIPTOR;
//            switch (code) {
//                case INTERFACE_TRANSACTION: {
//                    reply.writeString(descriptor);
//                    return true;
//                }
//                case TRANSACTION_getBookList: {
//                    data.enforceInterface(descriptor);
//                    java.util.List<Book> _result = this.getBookList();
//                    reply.writeNoException();
//                    reply.writeTypedList(_result);
//                    return true;
//                }
//                case TRANSACTION_addBook: {
//                    data.enforceInterface(descriptor);
//                    Book _arg0;
//                    if ((0 != data.readInt())) {
//                        _arg0 = Book.CREATOR.createFromParcel(data);
//                    } else {
//                        _arg0 = null;
//                    }
//                    this.addBook(_arg0);
//                    reply.writeNoException();
//                    return true;
//                }
//                case TRANSACTION_registerListener: {
//                    data.enforceInterface(descriptor);
//                    IOnBookListener _arg0;
//                    _arg0 = IOnBookListener.Stub.asInterface(data.readStrongBinder());
//                    this.registerListener(_arg0);
//                    reply.writeNoException();
//                    return true;
//                }
//                case TRANSACTION_unregisterListener: {
//                    data.enforceInterface(descriptor);
//                    IOnBookListener _arg0;
//                    _arg0 = IOnBookListener.Stub.asInterface(data.readStrongBinder());
//                    this.unregisterListener(_arg0);
//                    reply.writeNoException();
//                    return true;
//                }
//                default: {
//                    return super.onTransact(code, data, reply, flags);
//                }
//            }
//        }

        @Override
        public IBinder asBinder() {
            return this;
        }

        private static class Proxy implements IBookManager {
            private android.os.IBinder mRemote;

            Proxy(android.os.IBinder remote) {
                mRemote = remote;
            }

            @Override
            public android.os.IBinder asBinder() {
                return mRemote;
            }

            public java.lang.String getInterfaceDescriptor() {
                return DESCRIPTOR;
            }

            @Override
            public java.util.List<Book> getBookList() throws android.os.RemoteException {
                android.os.Parcel _data = android.os.Parcel.obtain();
                android.os.Parcel _reply = android.os.Parcel.obtain();
                java.util.List<Book> _result;
                try {
                    _data.writeInterfaceToken(DESCRIPTOR);
                    boolean _status = mRemote.transact(Stub.TRANSACTION_getBookList, _data, _reply, 0);
                    if (!_status && getDefaultImpl() != null) {
                        return getDefaultImpl().getBookList();
                    }
                    _reply.readException();
                    _result = _reply.createTypedArrayList(Book.CREATOR);
                } finally {
                    _reply.recycle();
                    _data.recycle();
                }
                return _result;
            }

            @Override
            public void addBook(Book book) throws android.os.RemoteException {
                android.os.Parcel _data = android.os.Parcel.obtain();
                android.os.Parcel _reply = android.os.Parcel.obtain();
                try {
                    _data.writeInterfaceToken(DESCRIPTOR);
                    if ((book != null)) {
                        _data.writeInt(1);
                        book.writeToParcel(_data, 0);
                    } else {
                        _data.writeInt(0);
                    }
                    boolean _status = mRemote.transact(Stub.TRANSACTION_addBook, _data, _reply, 0);
                    if (!_status && getDefaultImpl() != null) {
                        getDefaultImpl().addBook(book);
                        return;
                    }
                    _reply.readException();
                } finally {
                    _reply.recycle();
                    _data.recycle();
                }
            }

            @Override
            public void registerListener(IOnBookListener listener) throws android.os.RemoteException {
                android.os.Parcel _data = android.os.Parcel.obtain();
                android.os.Parcel _reply = android.os.Parcel.obtain();
                try {
                    _data.writeInterfaceToken(DESCRIPTOR);
                    _data.writeStrongBinder((((listener != null)) ? (listener.asBinder()) : (null)));
                    boolean _status = mRemote.transact(Stub.TRANSACTION_registerListener, _data, _reply, 0);
                    if (!_status && getDefaultImpl() != null) {
                        getDefaultImpl().registerListener(listener);
                        return;
                    }
                    _reply.readException();
                } finally {
                    _reply.recycle();
                    _data.recycle();
                }
            }

            @Override
            public void unregisterListener(IOnBookListener listener) throws android.os.RemoteException {
                android.os.Parcel _data = android.os.Parcel.obtain();
                android.os.Parcel _reply = android.os.Parcel.obtain();
                try {
                    _data.writeInterfaceToken(DESCRIPTOR);
                    _data.writeStrongBinder((((listener != null)) ? (listener.asBinder()) : (null)));
                    boolean _status = mRemote.transact(Stub.TRANSACTION_unregisterListener, _data, _reply, 0);
                    if (!_status && getDefaultImpl() != null) {
                        getDefaultImpl().unregisterListener(listener);
                        return;
                    }
                    _reply.readException();
                } finally {
                    _reply.recycle();
                    _data.recycle();
                }
            }

            public static IBookManager sDefaultImpl;
        }

        public static IBookManager getDefaultImpl() {
            return Stub.Proxy.sDefaultImpl;
        }
    }
}
